package cn.hfuu.socket;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author oldliu
 * @since 1.0
 */
public class ChatServer2 {
    public static void main(String[] args) {
        try {
            ServerSocket st = new ServerSocket(9999);
            System.out.println("服务器启动了");
            //线程池
            ExecutorService service = Executors.newFixedThreadPool(20);

            while (true) {
                final Socket s = st.accept();//接受连接
                service.submit(new ChatThread(s));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
